<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:pe="http://primefaces.org/ui/extensions">
    <h:head>
        <title>Trial Balance</title>
        <link href="./resources/css/default.css" rel="stylesheet" type="text/css" />
    </h:head>
    <h:body>
        <ui:composition>
            <h:form>
                                
                <p:toolbar style="width: 100%;">
                    <p:toolbarGroup align="left">
                        <p:commandButton value="#{bundle.btnLoad}" action="#{trialBalanceBean.loadData()}"
                                         update="dtTrialBalances" icon="ui-icon-arrowrefresh-1-w" /> 
                        
                        <p:commandButton type="push" action="#{rptGlbalanceBean.execute(trialBalanceBean.glbalances)}" value="#{bundle.btnPrint}"  
                                         ajax="false" image="ui-icon-print" >
                            <f:setPropertyActionListener value="#{0}" target="#{rptGlbalanceBean.reportId}" />
                            <f:setPropertyActionListener value="#{trialBalanceBean.startDate}" target="#{rptGlbalanceBean.startDate}" />
                            <f:setPropertyActionListener value="#{trialBalanceBean.endDate}" target="#{rptGlbalanceBean.endDate}" />
                            <f:setPropertyActionListener value="#{trialBalanceBean.branchId}" target="#{rptGlbalanceBean.branchId}" />
                        </p:commandButton>
                        
                    </p:toolbarGroup>
                </p:toolbar>
                
                <h:panelGrid id="displayTrialbalance" cellspacing="0" cellpadding="0" border="0" style="width: 100%;">
                    <p:panel header="Filter Data" style="height: 110px; width: 100%;">
                        
                        <h:panelGrid columns="2" border="0" cellpadding="0" cellspacing="5" columnClasses="panelGridId,panelGridId">
                            <p:outputPanel>
                                <h:panelGrid columns="3" border="0" cellpadding="0" cellspacing="3" rowClasses="panelGridId">
                                    <h:outputLabel value= "#{bundle.branch}" /><h:outputLabel value= ":" />
                                    <p:selectOneMenu value="#{trialBalanceBean.branchId}" style="width: 255px;" >
                                        <f:selectItem itemValue="0" itemLabel="Semua Cabang"/>
                                        <f:selectItems value="#{trialBalanceBean.avblBranch}"/>
                                    </p:selectOneMenu>
                                </h:panelGrid>
                            </p:outputPanel>    
                            
                            <p:outputPanel>
                                <h:panelGrid columns="4" border="0" cellpadding="0" cellspacing="3" rowClasses="panelGridId">
                                    <h:outputLabel value= "Period" /><h:outputLabel value= ":" />
                                    <p:spinner value="#{trialBalanceBean.year}" min="1945" max="3000" >
                                        <p:ajax listener="#{trialBalanceBean.changeDate}" update="tbStartDate tbEndDate" />  
                                    </p:spinner>

                                    <p:selectOneMenu value="#{trialBalanceBean.period}" style="width: 130px;" >
                                        <f:selectItems value="#{trialBalanceBean.avblPeriod}"/>
                                        <p:ajax listener="#{trialBalanceBean.changeDate}" update="tbStartDate tbEndDate" process="@this"/>  
                                    </p:selectOneMenu>
                                                        
                                    <h:outputLabel value= "#{bundle.date}" /><h:outputLabel value= ":" />
                                    <p:calendar id="tbStartDate" value="#{trialBalanceBean.startDate}" pattern="dd/MM/yyy" showOn="button"  size="18"
                                                maxdate="#{trialBalanceBean.maxDate}" mindate="#{trialBalanceBean.minDate}"/>
                                    <h:panelGrid columns="3" border="0" cellpadding="0" cellspacing="2">
                                        <h:outputLabel value= "s.d"/><p:spacer width="3" />
                                        <p:calendar id="tbEndDate" value="#{trialBalanceBean.endDate}" pattern="dd/MM/yyy" showOn="button" size="8"
                                                maxdate="#{trialBalanceBean.maxDate}" mindate="#{trialBalanceBean.minDate}"/>
                                    </h:panelGrid>
                                </h:panelGrid>
                            </p:outputPanel>    
                        </h:panelGrid>
                    </p:panel>
                    
                    <p:panel header="#{bundle.glaccnt}" style="height: 70%; width: 100%;" >
                        <h:panelGrid columns="3" border="0" cellpadding="0" cellspacing="5">
                            <p:dataTable id="dtTrialBalances" value="#{trialBalanceBean.glbalances}" var="gl" rowIndexVar="noUrut" 
                                         resizableColumns="true" scrollable="true" scrollHeight="280" >
                                <p:column width="12" headerText="No." footerText="">
                                    <h:outputText value="#{noUrut+1}" />
                                </p:column>
                               
                                <p:column width="70" headerText="No." footerText="">
                                    <f:facet name="header">#{bundle.accountNo}</f:facet>
                                    <h:outputText value="#{gl.accountNo}" />
                                </p:column>
                                
                                <p:column width="300" headerText="#{bundle.accountName}" footerText="">
                                    <h:outputText value="#{gl.accountName}" />
                                </p:column>
                                
                                <p:column width="100" headerText="#{bundle.saldoAwal}" footerText="" style="text-align:right">
                                    <h:outputText value="#{gl.awal}" styleClass="numPos">
                                        <f:convertNumber groupingUsed="true" />
                                    </h:outputText>
                                </p:column>    
                                <p:column width="100" headerText="#{bundle.debet}" footerText="#{trialBalanceBean.sumDebit}" style="text-align:right">
                                    <h:outputText value="#{gl.total01}" styleClass="numPos">
                                        <f:convertNumber groupingUsed="true" />
                                    </h:outputText>
                                </p:column>
                                
                                <p:column width="100" headerText="#{bundle.credit}" footerText="#{trialBalanceBean.sumCredit}" style="text-align:right">
                                    <h:outputText value="#{gl.total02}" styleClass="numPos">
                                        <f:convertNumber groupingUsed="true" />
                                    </h:outputText>
                                </p:column>
                                
                                <p:column width="100" headerText="#{bundle.change}" footerText="" style="text-align:right">
                                    <h:outputText value="#{gl.total}" styleClass="numPos">
                                        <f:convertNumber groupingUsed="true" />
                                    </h:outputText>
                                </p:column>
                                
                                <p:column width="100" headerText="#{bundle.balance}" footerText="" style="text-align:right">
                                    <h:outputText value="#{gl.saldo}" styleClass="numPos">
                                        <f:convertNumber groupingUsed="true" />
                                    </h:outputText>
                                </p:column>
                                
<!--                                <p:columnGroup type="footer">  
                                    <p:row>  
                                        
                                        <p:column footerText="s" />  
                                        <p:column footerText="s" /> 
                                        <p:column footerText="s" /> 
                                        <p:column footerText="Totals:"  style="text-align:right"  />  
                                        <p:column style="text-align:right" footerText="#{0}" />
                                        <p:column style="text-align:right" footerText="#{0}" />
                                                        
                                        <p:column footerText="s" />  
                                        <p:column footerText="s" />  
                                    </p:row>  
                                </p:columnGroup>  -->
                                
                            </p:dataTable>
                        </h:panelGrid>
                    </p:panel>
                </h:panelGrid>
            </h:form>
        </ui:composition>
    </h:body>
</html>